import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { ElNotification } from "element-plus"; //处理导航信息
import { WarningNoticeConfig } from "@/api/backend/index";

export const useWarningNoticeConfig = defineStore(Names.WarningNoticeConfig, {
  state: () => {
    return {
      single: <any>{},
      tags: <any>{},
      type: <any>[],
      typeWay: <any>[],
    };
  },
  getters: {},
  actions: {
    //获取告警通知配置列表数据
    getWarningNoticeConfigList(filter: any) {
      return new Promise((resolve, reject) => {
        _get(WarningNoticeConfig + "/list", filter, "json", "")
          .then((res: any) => {
            console.log("获取告警配置列表数据", res);
            resolve(res.rows);
          })
          .catch((err: any) => {
            reject(err);
          });
      });
    },
    //通过Id获取告警配置数据
    getWarningNoticeConfigById(filter: any) {
      return new Promise((resolve, reject) => {
        _get(WarningNoticeConfig + "/" + filter.noticeConfigId, {}, "json", "")
          .then((res: any) => {
            console.log("通过Id获取告警配置数据", res);
            resolve(res.data);
          })
          .catch((err: any) => {
            reject(err);
          });
      });
    },
  },
});
